<template>
  <div class="Home">
    <My-Home-Swipe :lunbo-urls="lunboUrls"></My-Home-Swipe>
    <Home-Container-New :todos="todos" :roll-info="rollInfo"></Home-Container-New>

    <Home-Footer></Home-Footer>
  </div>


</template>

<script>
  import {mapState, mapMutations, mapGetters} from 'vuex';
  import {Swipe, SwipeItem} from 'mint-ui';
  import {MessageBox} from 'mint-ui';
  import MyHomeSwipe from './component/MyHomeSwipe';
  import HomeList from './component/HomeList';
  import HomeContainerNew from './component/HomeContainerNew'
  import HomeFooter from '../../pages/footer'
  import bus from '../../eventbus/bus'

  export default {
    name: "HomeNew",
    data() {
      return {
        todos: [],
        lunboUrls: [],
        rollInfo: ''
      }
    },
    components: {
      MyHomeSwipe,
      HomeList,
      HomeContainerNew,
      HomeFooter
    },
    mounted: function () {
      this.getData();
    },
    methods: {
      getData() {
        //获取商品列表
        this.$axios.get(this.$apis.home).then(res => {
          console.log(res);
          let code = res.data.code;
          if (code === 1) {
            this.todos = res.data.data.goods;
            this.rollInfo = res.data.data.rollInfo;
            this.lunboUrls = res.data.data.homeSwipeUrls;
            bus.$emit("inf", this.rollInfo)

          } else {
            //弹错误提示
            this.$myUtils.bottomToast(res.data.msg)
          }

        })
          .catch(error => {
            this.$myUtils.bottomToast(error)
          })
      }
    },
    beforeDestroy() {
      bus.$off("inf")
    }

  }
</script>

<style>
  .Home {
    border-bottom: 10px;
  }

  .Homeheader i {
    font-size: 0.55rem;
  }

  .Homeheader {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1;
    height: 1.3rem;
    line-height: 1.3rem;
    font-size: 0.35rem;
    padding-left: 0.3rem;
    background: white;
  }

  .swipe {
    height: 6.5rem;
    margin-top: 1px;
  }

  .swipe img {
    width: 100%;
    height: 6.5rem;
  }

  .official {
    width: 100%;
    height: 0.8rem;
    background: white;
    margin-top: 1.33rem;
  }
</style>

